package com.example.backend.dao;

import com.example.backend.mapper.generator.TemperaturePoMapper;
import com.example.backend.mapper.po.TemperaturePoExample;
import com.example.backend.model.CloneFactory;
import com.example.backend.model.SensorData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class TemperatureDao {
    private TemperaturePoMapper temperaturePoMapper;

    @Autowired
    public TemperatureDao(TemperaturePoMapper temperaturePoMapper) {
        this.temperaturePoMapper = temperaturePoMapper;
    }

    public List<SensorData> retrieve(TemperaturePoExample example) {
        return this.temperaturePoMapper.selectByExample(example).stream().map(po -> CloneFactory.copy(new SensorData(), po)).toList();
    }

}
